package com.instasale.services;

import com.instasale.dao.SellerDAO;
import com.instasale.models.Seller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private SellerDAO sellerDAO;

    @Override
    @Transactional
    public void addSeller(Seller seller) {
        sellerDAO.addSeller(seller);
    }

    @Override
    @Transactional
    public List<Seller> listSeller() {
        return sellerDAO.listSeller();
    }

    @Override
    @Transactional
    public void removeSeller(Integer id) {
        sellerDAO.removeSeller(id);
    }

    @Override
    @Transactional
    public Seller getById(Integer id) {
        return (id == null) ? null : sellerDAO.getById(id);
    }
}
